# from flask import Flask, redirect, request, session, jsonify
# import requests
#
# app = Flask(__name__)
# app.secret_key = 'e-web'
# CLIENT_ID = 'c3695dcf852f3ec8d4d1089e50f4c846cd6a6d872013a6e6b9e797598da43760'
# CLIENT_SECRET = 'f42e6e47b15836d26b01e988674bcdd3fc7fda9dbf709c402732c88e6a5bcf90'
# REDIRECT_URI = 'http://localhost:5000/auth'
# AUTHORIZE_URL = 'https://gitee.com/oauth/authorize'
# ACCESS_TOKEN_URL = 'https://gitee.com/oauth/token'
# USER_INFO_URL = 'https://gitee.com/api/v5/user'
#
#
# @app.route('/')
# def index():
#     return 'Welcome to the login page! <a href="/login">Login with Gitee</a>'
#
#
# @app.route('/login')
# def login():
#     auth_url = f'{AUTHORIZE_URL}?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&response_type=code'
#     return redirect(auth_url)
#
#
# @app.route('/auth')
# def callback():
#     code = request.args.get('code')
#     payload = {
#         'client_id': CLIENT_ID,
#         'client_secret': CLIENT_SECRET,
#         'code': code,
#         'grant_type': 'authorization_code',
#         'redirect_uri': REDIRECT_URI,
#     }
#     response = requests.post(ACCESS_TOKEN_URL, data=payload)
#     access_token = response.json().get('access_token')
#
#     user_response = requests.get(USER_INFO_URL, headers={'Authorization': f'Bearer {access_token}'})
#     user_info = user_response.json()
#     user = {
#         "id": user_info["id"],
#         "username": user_info["login"],
#         "name": user_info["name"]
#     }
#     return jsonify(user)
#
#
# if __name__ == '__main__':
#     app.run(debug=True)
